package com.yan.shopping.domain;

import com.yan.shopping.dao.ProName;

import java.math.BigDecimal;

public class Product {
    private String id;
    private ProName name;
    private BigDecimal price;
    private Integer stock;

    public Product(String id, ProName name, BigDecimal price, Integer stock) {
        this.id = id;
        this.name = name;
        this.price = price;
        this.stock = stock;
    }

    public Product() {

    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public ProName getName() {
        return name;
    }

    public void setName(ProName name) {
        this.name = name;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public Integer getStock() {
        return stock;
    }

    public void setStock(Integer stock) {
        this.stock = stock;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Product product = (Product) o;

        if (id != null ? !id.equals(product.id) : product.id != null) return false;
        if (name != product.name) return false;
        if (price != null ? !price.equals(product.price) : product.price != null) return false;
        return stock != null ? stock.equals(product.stock) : product.stock == null;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (price != null ? price.hashCode() : 0);
        result = 31 * result + (stock != null ? stock.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return   id +"\t\t" + name + "\t\t" + price + "\t\t" + stock;
    }
}
